using UnityEngine;
using System.Collections;

public class BulletMultiShot : MonoBehaviour {

	public float spread = 2f;

	// Use this for initialization
	void Start () {
		int i = 0;
		int c = transform.childCount;

		while( transform.childCount > 0 ) {
			Transform t = transform.GetChild(0);

			float offset=0;
			if(c % 2 == 0)
				offset = 0.5f;

			t.rigidbody2D.velocity = Quaternion.Euler(0, 0, ((i - c/2) + offset) * spread ) * (rigidbody2D.velocity.normalized * t.GetComponent<BulletBehaviour>().bulletSpeed);
			t.SetParent(null);

			i++;
		}

		Destroy (gameObject);
	}
	
}
